home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
VideoToolbox 96.06.15
/
VideoToolboxSources
/
VideoToolbox.h
< prev
next >
Wrap
Text File
|
1996-06-07
|
49KB
|
1,372 lines
/*
VideoToolbox.h
This file contains the necessary prototypes for use of all the VideoToolbox
files except Luminance.c, which has its own header file, Luminance.h, and
GDInfo.c and GDTestClut.c, which use GDInfo.h.
Precompilation of this header, producing either VideoToolbox????.pre or
VideoToolboxMATLAB????.pre, will reduce your compilation time tenfold. See
VideoToolbox.pch, or VideoToolbox.c, or VideoToolboxMATLAB.c for instructions.
My convention is to assign different names to the precompiled header depending
on the compile-time options: use of ppc/68k, 68881, and size of int.
The precompilation depends on the sizeof(double) and sizeof(int)
because most functions use or return such values and the external interface must
allow the appropriate amount of space. THINK C supports a 12-byte "universal"
format double that works well both with the 68881 fpu (which uses the top two
bytes and the bottom 8 bytes) and with SANE (which uses the bottom 10 bytes).
Thus in THINK C it is easy to mix modules compiled with (e.g. your code) and
without (e.g. the ANSI library) the 68881 option. Unfortunately that excellent
feature is unique to THINK C. In MPW and CodeWarrior C you must use 10-byte
doubles when you use SANE (i.e. don't use the 68881 fpu), so when you use these
compilers you'll need separate pre-compiled headers, with and without the 68881
option, if you want to compile for each environment: to use the 68881 fpu, or
run on machines that lack it.
Metrowerks CodeWarrior project names end in "µ", and indicate which cpu they
support by "68k" or "ppc". THINK C projects support only the 68k and have names
ending in "π".
My naming convention for pre-compiled headers indicates the size of int, "2i" or
"4i", and, if the 68881 is required, "881". Metrowerks pre-compiled headers
indicate which cpu they support by "68k" or "ppc"; THINK C supports only the
68k. The THINK C pre-compiled header that I use is "VideoToolbox.pre", which
uses 2-byte ints and "universal" 12-byte doubles that work with or without the
68881. (The THINK C ANSI library requires 2-byte ints.) The Metrowerks
CodeWarrior C pre-compiled headers that I use are called,
"VideoToolbox.68k.4i.pre", "VideoToolbox.68k.4i.881.pre", and
"VideoToolbox.ppc.pre".
As of June 14, 1995, the VideoToolbox #includes <assert.h>, or, if MATLAB
is true, defines a MATLAB-compatible version of assert(). If your source file
#includes <assert.h> then it will be included again, which will obviate the work
done here, including the MATLAB compatibility. For that reason you should NOT
#include <assert.h> in your source files.
MAC_C:
Defining the symbol MAC_C as 0 before this file is compiled will leave only the
stuff that is written in pure Standard C, which will work on any computer.
The Apple Macintosh header files use some extensions to C that are not part of
Standard C, e.g. "pascal", "short double", enums larger than ints, and function
prototypes that specify absolute addresses. These keywords and constructions
cannot be compiled in Standard C. The macro MAC_C is defined as true, below,
only on Macintosh C compilers that incorporate these extensions, and is false
otherwise. The MAC_C symbol is used to prevent inclusion of all the
Macintosh-dependent header files and prototypes when the compiler doesn't
support them. However, lacking any general test for these extensions, a test
must be added, below, for each new compiler. At present we test for Symantec C
THINK C, Apple MPW C, and Metrowerks CodeWarrior C.
MATLAB:
The VideoToolbox sources can be linked to create a stand-alone C application, or
a MATLAB external code resource (a "MEX" file), to be invoked by typing the
function name from within MATLAB. In that case we call the THINK C project a
"MATLAB project". A MATLAB project must #define the symbol MATLAB as true for
every C file, must #include the VideoToolbox.h header at the beginning of every
C file, and must #include MATLABMain.h in the main C file.
You must have the file "cmex.h" in order to compile this file when "MATLAB" is true.
"cmex.h" is distributed by MathWorks as part of MATLAB.
Don't #define MATLAB within your C file; use the Edit:Options:THINK C:Prefix
window instead. E.g. you could type
#define MATLAB 1
into the Prefix window, or, more conveniently (because it speeds up your
compilations enormously), type
#include "VideoToolboxMATLAB.pre"
See VideoToolboxMATLAB.c for instructions.
The MATLABMain.h header allocates space for QuickDraw globals for use by THINK C
MATLAB projects. It should be #included in the main C file of each THINK C
MATLAB project, i.e. in the C file that contains "main" or "user_fcn". It must
be included in exactly one source file of each project, as the THINK C Linker
will otherwise complain.
dgp & dhb.
Copyright 1989-1994 © Denis G. Pelli
HISTORY: (omitting changes documented in C files)
2/20/93 dhb Added various commonly used headers.
Restructured so that only VideoToolbox.h has to be included,
whether one is creating stand-alone THINK C or code resources
to be called by MATLAB. Everything that cares is properly conditioned
by the symbol MATLAB.
7/9/93 dgp Changed our convention for the MATLAB symbol, defining it as
1 or 0 instead of defining or leaving undefined. The advantage of
this approach is that "MATLAB" can now be used as an argument in an
ordinary if statement, which is much more readable than #if.
8/21/93 dhb Added undefs in #if MATLAB so that memory allocation goes through THINK C
library, not as callback. Callbacks would be OK except that the Mathworks
forgot to give us one for realloc. This leads to mixing memory managers
on the same pointers -- bad bad bad.
9/2/93 dhb commented out #include <TranslateLinefeeds.h> since it's
not presently compatible with MATLAB.
9/2/93 dgp Moved the NL and NEWLINE macros from Assign.c into this file.
9/8/93 dgp Mention VideoToolbox.c.
9/11/93 dhb,dgp Define STDIO_INT and STDIO_DOUBLE.
9/12/93 dhb Change STDIO_... to PRINTF_... and SCANF_...
Insert conditional for MATLAB 3.5 vs. 4.x
9/14/93 dhb Conditional for MATLAB changed to make symbol match major version number.
Removed traces of old trying to force 4 byte ints for MATLAB.
9/14/93 dgp Moved up inclusion of QuickDraw.h before MATLAB stuff, since cmex.h
requires it. Fixed typo, changing "#elseif" to "#elif".
9/15/93 dgp Edited the comments above, referring to VideoToolbox.c and the new
VideoToolboxMATLAB.c.
9/16/93 dgp Added contents of former Assign.h.
Defined MAC_C so that the VideoToolbox.h header may be used with
Standard C.
9/16/93 dhb Removed prototype for obsolete GetDateTimeString.
10/2/93 dgp Added #include <Errors.h>.
12/1/93 dgp Now always write "MATLAB" in all caps, since that's the trademarked name.
12/16/93 dhb Somewhere things got munged. Conditional for MATLAB version appeared
before inclusion of cmex, which won't work. I fixed the order.
12/16/93 dhb Commented out inclusion of TranslateLineFeeds.h down below. This
generates a link error from MATLAB.
12/29/93 dgp added #include <Packages.h>
6/12/94 dgp added definition of Apple's new BlockMoveData, for compatibility with
Apple's old pre-Universal header files.
6/12/94 dgp #include Strings.h if Universal header files are used.
7/28/94 dgp Added test for Metrowerks CodeWarrior C.
9/2/94 dgp #include MacMemory.h
9/5/94 dgp changed "int" to "short int" in definitions of PRINTF_INT and SCANF_INT for
MATLAB 4. This is based on common sense, not testing or detailed knowledge.
3/31/95 dgp As a gesture of support for Symantec THINK C 8, now define THINK_C.
5/26/95 dgp Formerly header files whose precompilation depends on the mc68881 or
mc68020 THINK C compiler options (i.e. math.h and mc68881.h) were omitted
from VideoToolbox.h so that the resulting precompiled header file could be
used in projects regardless of those options. However, for Metrowerks CodeWarrior
there's no advantage to omitting those headers, and a significant increase in
compile time, as fp.h is recompiled for each file. Since I've switch to
CodeWarrior, and expect most other users to switch as well, VideoToolbox.h now
includes math.h or fp.h.
5/27/95 dgp removed fp.c prototypes because Apple's fp.h now supports both 68k and ppc.
6/6/95 dgp discarded all references to TranslateLinefeeds.c and TranslateLinefeeds.h, since
I never got them to work properly, and I don't think they're needed with Metrowerks
CodeWarrior.
6/8/95 dgp Made sure that the MATLAB struct "Matrix" is always native aligned.
6/13/95 dgp define GENERATING68K, GENERATINGPOWERPC, and GENERATING68881 if not already
defined (as in Apple's latest universal headers). Define GENERATING68020.
6/14/95 dhb & dgp redefine the assert() macro, redirecting it to PrintfExit, which
in turn uses mex_error() to report the error. This is needed to get MEX files
to link properly.
6/16/95 dhb Fixed MATLAB's SCANF_INT etc. for __MWERKS__.
6/16/95 dgp moved the definitions of GENERATING68K to the top of this file, so that
the MATLAB conditionals can use them.
6/16/95 dhb & dgp now #include <assert.h>, unless MATLAB is defined, in which case
we define a MATLAB-compatible version of the assert macro. Just in case,
leave NDEBUG defined to disable the standard assert macro which may be
brought in if the user's source files #include <assert.h>.
6/16/95 dhb Fixed longstanding bug (in SCANF_INT??).
6/23/95 dhb Include prototypes for AfterDark.c and IsFileSharingOn.c.
7/19/95 dgp Added changes suggested by Stefan Treue, streue@bcm.tmc.edu, for compatibility
with Symantec C. Eliminated use of //-style comments. Now include math.h
when compiling for Standard C, i.e. MAC_C is false.
8/10/95 dgp Include MacMemory.h ONLY for THINK C, not for Symantec C, since I don't
have any reason to think that Symantec C memory management is bad.
8/13/95 dgp Removed definition of THINK_C for SYMANTEC_C. It seems better to leave
the compiler's macros alone. Changed conditionals throughout the VideoToolbox
to deal with all the special cases: THINK_C, THINK_CPLUS, and SYMANTEC_C.
3/5/96 dhb Add conditional to prevent inclusion of <fp.h> and instead include <math.h>
when THINK_C is true. This is needed to compile under THINK_C 8. I suspect
that this used to work because the universal headers variable was < 2.
4/1/96 dgp removed "MAC_C" requirement for inclusion of fp.h. Tried to make VideoToolbox.h
more consistent with q_include.h, so both will work separately or together, in
either order, but I haven't checked whether I succeeded.
*/
#pragma once /* suppress multiple inclusions of this file */
#ifndef _VIDEOTOOLBOX_ /* suppress multiple inclusions of this file */
#define _VIDEOTOOLBOX_
/*
Header files that are required for successful compilation of the rest of this
file are marked "required".
*/
#if !defined(MAC_C)
#if THINK_C || THINK_CPLUS || SYMANTEC_C \
|| applec /* MPW C, presumably with Mac extensions */ \
|| __MWERKS__ /* Metrowerks CodeWarrior C, " */
/* Set MAC_C to true only if the "pascal" keyword is allowed. */
#if THINK_C && !SYMANTEC_C
#if !__option(thinkc)
#define MAC_C 0 /* Standard C */
#endif
#endif
#if SYMANTEC_C
#if __option(ansi_strict)
#define MAC_C 0 /* Standard C */
#endif
#endif
#if __MWERKS__
#if __option(ANSI_strict) || __option(only_std_keywords)
#define MAC_C 0 /* Standard C */
#endif
#endif
#if !defined(MAC_C)
#define MAC_C 1 /* allow Mac C extensions: "pascal", etc. */
#endif
#else
#define MAC_C 0 /* Standard C */
#endif
#endif
#ifndef SHORT_DOUBLE_OK
#if SYMANTEC_C
#define SHORT_DOUBLE_OK 0 /* "short double" not supported by Symantec C */
#else
#define SHORT_DOUBLE_OK MAC_C /* "short double" not allowed by Standard C */
#endif
#endif
#include <stdio.h> /* required */
#include <stdlib.h>
#if MAC_C
#include <Quickdraw.h> /* required */
#endif
/*
The inclusion, above, of Quickdraw.h will result in the inclusion of MixedMode.h
only if the Universal Headers are used, since the Universal Headers and the Mixed
Mode Manager are both new, providing universal support for 68k and ppc Macs.
*/
#if defined(__MIXEDMODE__)
#if defined(GENERATINGPOWERPC) || defined(GENERATING68K)
#define UNIVERSAL_HEADERS 2 /* version 2 */
#else
#define UNIVERSAL_HEADERS 1 /* version 1 */
#endif
#else
#define UNIVERSAL_HEADERS 0
#endif
/*
Based on Apple's ConditionalMacros.h, so that the VideoToolbox and your sources
can use these new macros without worrying about whether you've actually got the
new headers (June '95) in which they are first introduced. This section has no effect if
GENERATINGPOWERPC etc. are already defined. These macros support early versions of
THINK C, which Apple's new headers don't support.
*/
#if !defined(GENERATINGPOWERPC) || !defined(GENERATING68K)
#undef GENERATINGPOWERPC
#undef GENERATING68K
#if defined(powerc) || defined(__powerc)
#define GENERATINGPOWERPC 1
#define GENERATING68K 0
#else
#define GENERATINGPOWERPC 0
#define GENERATING68K 1
#endif
#endif
#if GENERATING68K && !defined(GENERATING68881)
#if defined(applec) || defined(__SC__)
#ifdef mc68881
#define GENERATING68881 1
#endif
#else
#if THINK_C && THINK_C==1 /* THINK C 4 */
#define GENERATING68881 _MC68881_
#endif
#if SYMANTEC_C || THINK_CPLUS || (THINK_C && THINK_C>1) /* THINK C 5,6,7,8, C++, SYMANTEC C,C++ */
#if __option(mc68881)
#define GENERATING68881 1
#endif
#endif
#ifdef __MWERKS__
#if __MC68881__
#define GENERATING68881 1
#endif
#endif
#endif
#endif
#ifndef GENERATING68881
#define GENERATING68881 0
#endif
/* Apple's headers don't define GENERATING68020, but Identify.c and Require.c need it. */
#if GENERATING68K && !defined(GENERATING68020)
#if defined(applec) || defined(__SC__)
#ifdef mc68020
#define GENERATING68020 1
#endif
#else
#if THINK_C && THINK_C==1 /* THINK C 4 */
#define GENERATING68020 _MC68020_
#endif
#if SYMANTEC_C || THINK_CPLUS || (THINK_C && THINK_C>1) /* Symantec C, THINK C 5,6,7,8 */
#if __option(mc68020)
#define GENERATING68020 1
#endif
#endif
#if __MWERKS__
#if __MC68020__
#define GENERATING68020 1
#endif
#endif
#endif
#endif
#if !defined(GENERATING68020)
#define GENERATING68020 0
#endif
#if !defined(MATLAB)
#define MATLAB 0
#endif
#if MATLAB
/*
This must come after stdlib.h, stdio.h, and QuickDraw.h and before everything
else. If MATLAB is true then we include the header file cmex.h. Otherwise we
define the data types that are normally provided by that header, so that code
that uses these types may be compiled for use in applications. It must come
before we test for version 3 or 4. The version 3 cmex.h does not define the
symbol mex_h; version 4 does. This is what we use to figure out which
version we are compiling for. Sound complicated? Sigh! dhb
*/
#include "cmex.h"
/* Test for MATLAB 4 or MATLAB 3, and set symbol appropriately. */
#undef MATLAB
#ifdef mex_h
#define MATLAB 4
#else
#define MATLAB 3
#endif
#if !MAC_C
#error "MATLAB requires the Macintosh extensions to C."
#endif
/*
Undefine the macros that override memory allocation. MATLAB's implementation
doesn't work if you use realloc.
*/
#undef malloc
#undef calloc
#undef free
/* Define data types for printf, scanf. */
#if MATLAB==4 /* Version 4 */
#if GENERATING68K
typedef short int PRINTF_INT; /* type of arguments to printf et al. */
typedef long double PRINTF_DOUBLE;
typedef int SCANF_INT; /* type of arguments to scanf et al. */
typedef double SCANF_DOUBLE;
#endif
#if GENERATINGPOWERPC
typedef int PRINTF_INT; /* type of arguments to printf et al. */
typedef double PRINTF_DOUBLE;
typedef int SCANF_INT; /* type of arguments to scanf et al. */
typedef double SCANF_DOUBLE;
#endif
#endif
#if THINK_C || THINK_CPLUS || SYMANTEC_C /* Declare our own QuickDraw globals, allocated by MATLABMain.h */
extern THINK_C_QD mex_qd;
#define qd mex_qd
#else
#define mex_qd qd
#endif
#else
typedef long int INT;
#if SHORT_DOUBLE_OK
typedef short double DOUBLE;/* not allowed by Standard C */
#else
typedef double DOUBLE;
#endif
typedef int PRINTF_INT; /* type of arguments to printf et al. */
typedef double PRINTF_DOUBLE;
typedef int SCANF_INT; /* type of arguments to scanf et al. */
typedef double SCANF_DOUBLE;
#if SHORT_DOUBLE_OK
#if PRAGMA_ALIGN_SUPPORTED || __MWERKS__
#pragma options align=native
#endif
typedef struct {
char *name;
INT type;
INT m;
INT n;
DOUBLE *pr;
DOUBLE *pi;
} Matrix;
#if PRAGMA_ALIGN_SUPPORTED || __MWERKS__
#pragma options align=reset
#endif
#endif
#endif
/* Standard C headers */
#if MATLAB
/* The <assert.h> macro requires modification to work in a MATLAB shared library. */
#define NDEBUG /* disable the standard assert.h macro */
#undef assert
#define assert(x) if(!(x)){\
PrintfExit("Assertion (" #x ") failed at %s:%d\n",__FILE__,__LINE__);\
}
#else
#include <assert.h>
#endif
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#if !defined(__MATH__) && (UNIVERSAL_HEADERS>=2) && !THINK_C
#include <fp.h>
#else
#if GENERATINGPOWERPC || GENERATING68881
/* as advised by math.h, we don't enable these if using 8-byte doubles on 68k */
#undef _NOERRORCHECK_
#undef _INLINE_FPU_CALLS_
#define _NOERRORCHECK_ 1 /* encourage use of 8881 intrinsic functions */
#define _INLINE_FPU_CALLS_ 1 /* encourage use of 8881 intrinsic functions */
#endif
#include <math.h>
#if !defined(__FP__) /* make sure that math.h hasn't included fp.h */
#undef round
#define round(x) floor(0.5+(x)) /* used by many VideoToolbox routines */
#endif
#endif
/* Macintosh headers */
#if MAC_C
#if THINK_C || THINK_CPLUS || SYMANTEC_C
#include <console.h>
#endif
#include <Devices.h>
#include <Errors.h>
#include <Events.h>
#include <FixMath.h>
#include <Fonts.h>
#if UNIVERSAL_HEADERS>2
#include <Gestalt.h> /* Apple abbreviated the filename */
#else
#include <GestaltEqu.h>
#endif
#include <Memory.h>
#include <Menus.h>
#include <OSEvents.h>
#include <OSUtils.h> /* required */
#include <Packages.h>
#include <Palettes.h>
#if (THINK_C || THINK_CPLUS || SYMANTEC_C)
#include <profile.h>/* only needed if you want timing info */
#endif
#include <QDOffscreen.h>
#include <Resources.h>
#include <Retrace.h> /* required */
#if __MWERKS__
#include <SIOUX.h>
#endif
#include <Slots.h>
#include <Sound.h>
#if THINK_C && !UNIVERSAL_HEADERS
#include <pascal.h> /* CtoPStr() and PtoCStr() */
#ifndef c2pstr
#define c2pstr(s) CtoPstr(s)
#define p2cstr(s) PtoCstr(s)
#endif
#else
#include <Strings.h>/* c2pstr() and p2cstr() */
#define CtoPstr c2pstr
#define PtoCstr p2cstr
#endif
#include <Timer.h> /* required */
#include <ToolUtils.h>
#include <Traps.h>
#include <Video.h>
#include <Windows.h> /* required */
/*
Old Memory.h header files, before Apple's Universal Headers, don't define the new
BlockMoveData(), so we do it here, to retain compability with the old header files.
*/
#if !UNIVERSAL_HEADERS
#pragma parameter BlockMoveData(__A0,__A1,__D0)
extern pascal void BlockMoveData(const void *srcPtr,void *destPtr,Size byteCount)=0xA22E;
#endif
#endif
/*
This redefines the standard C functions, malloc, etc. to instead call Apple's
corresponding routines, e.g. NewPtr. The THINK C memory management routines are
poor because they are bad about freeing space, tending to fragment the free space.
*/
#if THINK_C && !defined(SYMANTEC_C)
#include "MacMemory.h"
#endif
/*
MATLAB AND THE NEWLINE CHARACTER
In most C environments the newline character is '\n' (ascii 10). In Apple's
wisdom they chose to separate lines in Macintosh files with the ascii 13
character, which is usually called the return character '\r'. Standard C
specifies that the stdio library will use '\n' as the newline character. This
potentially creates a compatibility problem between Mac C programs and C
programs written for the rest of the world's computers, since one wants any text
files they produce to be appropriate to the local environment. Both MPW and
THINK C resolve the problem behind the scenes, but they do it in different ways.
MPW redefines the association between symbolic names and character codes, making
'\n' be 13 and '\r' be 10. THINK C instead modifies the stdio library so that
reads and writes to a "text" (i.e. not binary) stream are translated, exchanging
character codes 10 and 13. Both solutions work. However, when we use THINK C to
create code resources for MATLAB we are forced to use the MPW stdio library that
is built into MATLAB. Unfortunately this bypasses both compilers' fixes to the
newline problem. The problem affects every single text i/o operation, e.g. every
printf and scanf. Alas, there is no way to get the pre-processor to redefine /n
and /r.
Our quick fix is to create a macro called NL that is normally defined as the
newline string "\n", but which is instead defined as "\015" (i.e. ascii 13) when
MATLAB is true. Programs such as Assign.c that have replaced all instances of
"\n" by NL will then work whether or not MATLAB is true. The obvious drawback is
that this quick solution requires these modifications to the source files.
*/
#if MATLAB && THINK_C /* Quick fix */
#define NL "\r"
#define NEWLINE '\r'
#else
#define NL "\n" /* the standard new-line string */
#define NEWLINE '\n'
#endif
/*
TRUE and FALSE
*/
#ifndef TRUE
#define FALSE 0
#define TRUE 1
#endif
/*
NAN & INF
If you're using NAN and INF you'll be interested in the IsNan(), IsInf(), and
IsFinite() definitions & prototypes below.
Apple's fp.h header defines isnan() and isfinite().
Apple's header files math.h and fp.h both define HUGE_VAL and pi.
fp.h also defines INFINITY, NAN, isfinite(), and isnan().
*/
#if !defined(INF)
#define INF HUGE_VAL /* HUGE_VAL is defined in math.h and fp.h */
#endif
#if !defined(NAN)
/* #define NAN (0.0/0.0) */ /* evaluated at runtime */
#define NAN Nan /* global defined in Nan.c */
#endif
/*
NUMERICAL CONSTANTS
It's sad to say, but THINK C 5.02 loses two bits of precision converting between
doubles and ascii text, in either direction. Thus you will obtain more accurate
results by computing the numerical constants below at runtime rather than using
these predefined constants. The ANSI Numerical C Extensions group is moving to
require C compilers to preserve precision, so there is hope for the future. Of
course most applications would never notice a loss of two bits precision out of
the total double precision given by the 64 bits in the mantissa.
*/
#if !defined(PI)
#if UNIVERSAL_HEADERS>=2
#define PI pi /* pi is defined in math.h and fp.h */
#else
#define PI 3.1415926535897932385 /* computed in Mathematica */
#endif
#endif
#if !defined(LOGPI)
#define LOGPI 1.14472988584940017414 /* computed in Mathematica */
#endif
#if !defined(LOG2)
#define LOG2 0.69314718055994530942 /* computed in Mathematica */
#endif
#if !defined(LOG10)
#define LOG10 2.30258509299404568402 /* computed in Mathematica */
#endif
#if MAC_C
/*
CLUTSIZE
Inline code that returns the same answer as GDClutSize(device).
*/
#define GDCLUTSIZE(device) (gdClutSizeTable[(**(**(device)).gdPMap).pixelSize])
/* Commented out, because its answer is misleading when in 16-bit or 32-bit mode. */
/* #define GDCOLORS(device) ((**(**(**device).gdPMap).pmTable).ctSize+1) */
#endif
/*
FIXED POINT ARITHMETIC
Apple defines a handy data type called Fixed that is stored in a long, but is
assumed to have a decimal point in the middle. Many operations, e.g. adding two
Fixed numbers or multiplying or dividing a Fixed by an integer, can be performed
directly. To multiply or divide two Fixed numbers use Apple's FixMul() and
FixDiv(). FixRatio(n,m) returns the Fixed ratio of two integers. Macintosh C
compilers define double in various ways, depending on whether a floating point
unit is to be used. The Apple-provided routines for doing type conversion to and
from Fixed are only appropriate if you are NOT using the floating point unit.
The ones defined below are faster and work with or without the FPU.
*/
#define LongToFix(x) ((long)(x)<<16)
#define FixToLong(x) ((x)>>16)
#define DoubleToFix(x) ((long)((x)*65536.+0.5))
#define FixToDouble(x) ((double)(x)*(1./65536.))
#if MAC_C
/*
StackGrow(n) increases the stack allocation by n bytes. You'll also want to use
Apple's StackSpace(), declared in Memory.h, that returns the number of bytes
allocated for the stack.
*/
#define StackGrow(extraBytes) SetApplLimit(GetApplLimit()-(extraBytes))
#endif
#if MAC_C
/* AfterDark.c */
OSErr AfterDarkEnable(void);
OSErr AfterDarkDisable(void);
#endif
/* Assign.c */
#define ASSIGN_DIMS 3 /* Feel free to increase or decrease ASSIGN_DIMS. */
typedef struct {
short type;
unsigned sizedOnce:1; /* dim[] is meaningful */
unsigned sized:1; /* dim[] is final */
unsigned malloced:1; /* allocated by malloc */
char *name;
void *ptr; /* for array, address of element zero */
long dim[ASSIGN_DIMS]; /* zero indicates a scalar */
long firstElement; /* for 1-d array, index of first array element. Usually 0 */
const char *comment; /* text string, or NULL */
} Description;
enum{assignReportUnknown=1,assignNoHexInts=2,assignHexFloats=4
,assignNoComment=8,assignNoPrintfExit=0x10
,assignEchoAssignments=0x20,assignEchoComments=0x40,assignEchoFile=0x80
};
enum {assignMemoryError=-1,assignTypeError=-2
,assignVariableError=-3,assignUnknownVariableError=-4
,assignSubscriptError=-5,assignSubscriptBoundsError=-6
,assignEqualsError=-7,assignConstantError=-8,assignHexError=-9
,assignSemicolonError=-10,assignFileError=-11
,assignInconsistentDescriptionsError=-12,assignUnequalDataError=-13
,assignInconsistentDimensionsError=-14
,assignCouldntFindDescription=-15
};
enum{charType=1,unsignedCharType,shortType,unsignedShortType
,longType,unsignedLongType
,floatType
#if SHORT_DOUBLE_OK
,shortDoubleType
#endif
,doubleType
,charPtrType,unsignedCharPtrType,shortPtrType,unsignedShortPtrType
,longPtrType,unsignedLongPtrType
,floatPtrType
#if SHORT_DOUBLE_OK
,shortDoublePtrType
#endif
,doublePtrType
,stringType,unknownType
};
FILE *OpenCalFileRead(char *filename);
FILE *OpenCalFileReadAndCheck(char *filename);
FILE *OpenCalFileWrite(char *filename);
void AppendDescriptions(Description **d,Description *s);
void CopyDescriptions(Description *d,Description *s);
Description *AllocateDescriptions(long n);
void FreeDescriptions(Description *d);
long NumberOfDescriptions(Description *d);
Description NullDescription(void);
int IsNullDescription(Description d);
#define IsNullDescription(d) ((d).type==0)
int AssignmentLineWasBlank(void);
int UnequalDescribedVars(Description d1[],Description d2[],short flags);
int UnequalDescribedVarPair(Description *d1,Description *d2,short flags);
int CopyDescribedVars(Description d1[],Description d2[],short flags);
int CopyDescribedVarPair(Description *d1,Description *d2,short flags);
long InitializeADescribedVar(Description *d,short flags);
long InitializeDescribedVars(Description d[],short flags);
long FindDescribedDim(Description d[],void *ptr,int i,short flags);
long FindDescription(Description d[],void *ptr,short flags);
void FreeADescribedVar(Description *d,short flags);
void FreeDescribedPtrVars(Description d[],short flags);
void FreeDescribedVars(Description d[],short flags);
void KeepDescribedVars(Description d[],short flags);
void KeepADescribedVar(Description *d,short flags);
long PrintAnAssignment(FILE *stream,Description *d,short flags);
long PrintAssignments(FILE *stream,Description d[],short flags);
long PrintAssignmentsToFile(const char *filename,Description d[],short flags);
long ReadAssignmentLine(FILE *stream,Description d[],short flags);
long ReadAssignmentBlock(FILE *stream,Description d[],short flags);
long ReadAssignmentStream(FILE *stream,Description d[],short flags);
long ReadAssignmentFile(const char *filename,Description d[],short flags);
Description Describe(short type,void *ptr,char *name,const char *comment);
Description DescribeArray(short type,void *ptr,char *name,const char *comment,...);
Description DescribeFirstLast(short type,void *ptr,char *name
,const char *comment,long firstElement,long lastElement);
#if MAC_C
/* AtExitToShell.c */
int AtExitToShell(void(*userFunctionPtr)(void));
#endif
/* Binomial.c */
long BinomialSample(double p,long n);
int BinomialSampleQuickly(int n);
double BinomialLowerBound(double P,long k,long n);
double BinomialUpperBound(double P,long k,long n);
double BinomialPdf(double p,long k,long n);
double Binomial(double p,long k,long n);
double IncompleteBeta(double x,double a,double b);
double InverseBinomial(double P,long k,long n);
double InverseIncompleteBeta(double p,double a,double b);
/* BreakLines.c */
char *BreakLines(char *string,long lineLength);
void PrintWrappedText(FILE *stream,const char *s);
void PrintWrappedTextToFile(const char *filename,const char *s);
void PrintWrappedComment(FILE *stream,const char *s);
void PrintWrappedCommentToFile(const char *filename,const char *s);
#if MAC_C
/* CardSlot.c */
OSErr CardSlot(char *cardName);
/* CenterRectInRect.c */
void CenterRectInRect(Rect *moveableRectPtr,Rect *fixedRectPtr);
void OffsetRectTile(Rect *r,int nx,int ny);
Boolean IsRectInRect(Rect *r,Rect *R);
void ShrinkRect(Rect *r,int hDivisor,int vDivisor);
void ExpandRect(Rect *r,double hMag,double vMag);
void ExpandAndOffsetRect(Rect *r,double hMag,double vMag,double hOffset,double vOffset);
void LocalToGlobalRect(Rect *r);
void GlobalToLocalRect(Rect *r);
#endif
/* ChiSquare.c */
double PChiSquare (double chiSquare,int n);
/* Choose.c */
#if !MAC_C
#define Boolean unsigned char
#endif
int Choose(int defaultChoice,const char *query,char *choices[],int n);
char *ChoiceStr(char *choices[],int n);
int MultipleChoice(short defaultChoice,short n,char *choices[]);
Boolean YesOrNo(Boolean defaultAnswer);
extern char *noYes[];
#if !MAC_C
#undef Boolean
#endif
#if MAC_C
/* ChooseScreen.c */
int ChooseScreen(int screen,const char *question);
/* ConvolveX.c */
void ConvolveX(double f[],int dim,BitMap *srcBits,BitMap *dstBits,
Rect *srcRectPtr,Rect *dstRectPtr);
/* ConvolveY.c */
void ConvolveY(double f[],int dim,BitMap *srcBits,BitMap *dstBits,
Rect *srcRectPtr,Rect *dstRectPtr);
/* CopyBitsQuickly.c */
enum{addOverQuickly=40,addOverParallel=40,mulOver};
int CopyBitsQuickly(BitMap *srcBits,BitMap *dstBits
,Rect *srcRectPtr,Rect *dstRectPtr,long srcMode,RgnHandle maskRgn);
/* CopyQuickDrawGlobals.c */
void CopyQuickDrawGlobals(void);
#define CopyQuickdrawGlobals CopyQuickDrawGlobals /* old spelling */
/* CopyWindows.c */
enum{copyLiterally=0x10000,copyColorize=0x20000};
enum{srcCopyLiterally=srcCopy+copyLiterally,addOverLiterally=addOver+copyLiterally
,addOverParallelLiterally=addOverParallel+copyLiterally
,mulOverLiterally=mulOver+copyLiterally};
int CopyWindows(CWindowPtr srcWindow,CWindowPtr dstWindow
,Rect *srcRectPtr,Rect *dstRectPtr,long srcMode,RgnHandle maskRgn);
/* CreateTrialSnds.c */
void CreateTrialSnds(void);
#endif
/* DatedString.c */
char *DatedString(unsigned long seconds);
#if MAC_C
/* DrawPrintf.c */
void DrawPrintf(char *s, ...);
#endif
/* Exponential.c */
double ExponentialPdf(double x);
/* ffprintf.c */
int ffprintf(FILE *stream[2],char *format,...);
#if MAC_C
/* FlushCacheRange.c */
void FlushCacheRange (void *address, unsigned long count);
/* GDOpenWindow.c */
void AddExplicitPalette(WindowPtr window);
void RemovePalette(WindowPtr window);
WindowPtr GDOpenWindow1(GDHandle device);
void GDDisposeWindow1(WindowPtr window);
CWindowPtr GDOpenWindow(GDHandle device);
void GDDisposeWindow(CWindowPtr myWindow);
void GDGrayColorTable(GDHandle device);
void SwapWindowExplicitMode(CWindowPtr window,Boolean *explicit);
BitMap *GetBitMapPtr(CWindowPtr window);
Boolean IsGWorldPtr(CWindowPtr window);
Boolean IsGrafPtr(CWindowPtr window);
/* GDPrintf.c */
void GDPrintf(char *s, ...);
/* GDTime.c */
double GDFrameRate(GDHandle device);
double GDMovieRate(GDHandle device,int quickly);
double GDMovieSize(GDHandle device,int quickly);
double GDVBLRate(GDHandle device);
double TickRate(void);
typedef OSErr (*SetEntriesFunction)(GDHandle device,short start,short count
,ColorSpec *aTable);
OSErr GDTimeClut(GDHandle device,SetEntriesFunction function,short clutEntries
,double *sPtr,double *framesPtr,double *missingFramesPtr,double *frameRatePtr);
/* GDVideo.c */
#define MAX_SCREENS 8
OSErr DriverGestalt(int refNum,OSType driverGestaltSelector,unsigned long *driverGestaltResponsePtr);
OSErr GDGestalt(GDHandle device,OSType driverGestaltSelector,unsigned long *driverGestaltResponsePtr);
Boolean GDGestaltIsOn(GDHandle device);
char *GDCardName(GDHandle device);
extern short gdClutSizeTable[33];
short GDClutSize(GDHandle device);
long GDColors(GDHandle device);
OSErr GDControl(int refNum,int csCode,Ptr csParamPtr);
short GDDacSize(GDHandle device);
OSErr GDDirectSetEntries(GDHandle device,short start,short count,ColorSpec *aTable);
OSErr GDDisposeGamma(GDHandle device);
OSErr GDGetDisplayMode(GDHandle device,unsigned long *displayModeIDPtr
,unsigned short *modePtr,unsigned short *pagePtr,Ptr *baseAddrPtr);
OSErr GDGetNextResolution(GDHandle device,unsigned long previousDisplayModeID
,unsigned long *displayModeIDPtr,unsigned long *horizontalPixelsPtr
,unsigned long *verticalLinesPtr,Fixed *refreshRatePtr
,unsigned short *maxDepthModePtr);
OSErr GDGetDefaultGamma(GDHandle device,GammaTbl **gammaTbl);
OSErr GDGetDefaultMode(GDHandle device,short *modePtr);
OSErr GDGetDelay(GDHandle device,Boolean *dontWaitForVBLPtr,double *nanosecondsPtr);
OSErr GDGetEntries(GDHandle device,short start,short count,ColorSpec *aTable);
OSErr GDGetGamma(GDHandle device,GammaTbl **myGammaTblHandle);
OSErr GDGetGray(GDHandle device,Boolean *flagPtr);
OSErr GDGetInterrupt(GDHandle device,Boolean *flagPtr);
OSErr GDGetMode(GDHandle device,short *modePtr,short *pagePtr,Ptr *baseAddrPtr);
OSErr GDGetPageBase(GDHandle device,short page,Ptr *baseAddrPtr);
OSErr GDGetPageCnt(GDHandle device,short mode,short *pagesPtr);
OSErr GDGrayPage(GDHandle device,short page);
Boolean GDHasMode(GDHandle device,short mode,short *pixelSizePtr,short *pagesPtr);
short GDModePixelSize(GDHandle device,short mode);
unsigned char *GDName(GDHandle device);
char *GDNameStr(GDHandle device);
ColorSpec *GDNewLinearColorTable(GDHandle device);
short GDPixelSize(GDHandle device);
OSErr GDPrintGammaTable(FILE *o,GDHandle device);
OSErr GDReset(GDHandle device,short *modePtr,short *pagePtr,Ptr *baseAddrPtr);
OSErr GDRestoreDeviceClut(GDHandle device);
OSErr GDRestoreGamma(GDHandle device);
OSErr GDSaveGamma(GDHandle device);
OSErr GDSetDefaultMode(GDHandle device,short mode);
OSErr GDSetDelay(GDHandle device,Boolean dontWaitForVBL,double nanoseconds);
OSErr GDSetEntries(GDHandle device,short start,short count,ColorSpec *aTable);
OSErr GDSetEntriesByType(GDHandle device,short start,short count,ColorSpec *table);
OSErr GDSetEntriesByTypeHighPriority(GDHandle device,short start,short count
,ColorSpec *table);
OSErr GDSetGamma(GDHandle device,GammaTbl *myGammaTblPtr);
OSErr GDSetGray(GDHandle device,Boolean flag);
OSErr GDSetInterrupt(GDHandle device,Boolean flag);
OSErr GDSetMode(GDHandle device,short mode,short page,Ptr *baseAddrPtr);
OSErr GDSetPageDrawn(GDHandle device,short page);
OSErr GDSetPageShown(GDHandle device,short page);
OSErr GDStatus(int refNum,int csCode,Ptr csParamPtr);
OSErr GDSwitchMode(GDHandle device,short mode,long displayModeID,short page,Ptr *baseAddrPtr);
short GDType(GDHandle device);
OSErr GDUncorrectedGamma(GDHandle device);
int GDVersion(GDHandle device);
int PatchMacIIciVideoDriver(void);
Boolean IsPCIMac(void);
void GDRestoreBlackAndWhite(GDHandle device);
/* GetClicks.c */
short GetClicks(void);
short GetNextEventOrQuit(int mask,EventRecord *eventPtr);
/* GetScreenDevice.c */
GDHandle GetScreenDevice(int n);
int GetScreenIndex(GDHandle device);
GDHandle SlotToScreenDevice(int n);
GDHandle GetDeviceByRefNum(int n);
short int GetDeviceSlot(GDHandle device); /* gives nonsense on PCI bus */
char *GetDeviceSlotName(GDHandle device); /* works on NuBus, PCI bus, and no bus */
GDHandle GetWindowDevice(WindowPtr theWindow);
GDHandle GetRectDevice(Rect *r);
#endif
/* GetTimeDateString.c */
char *GetTimeDateString(time_t t);
#if MAC_C
/* GetVersionString.c */
char *GetVersionString(void);
/* GetVoltage.c */
double VoltsDuringFrame(double frames);
double GetVoltage(short channel,double *gainPtr,double *frequencyPtr,long n
,double *sdPtr);
short GetVoltages(short channel,double *gainPtr,double *frequencyPtr,long *nPtr
,unsigned short readings[],double *voltDeltaPtr,double *voltZeroPtr);
short InitiateVoltageSampling(short channel,double *gainPtr,double *frequencyPtr
,double *voltDeltaPtr,double *voltZeroPtr);
short RetrieveVoltages(long *nPtr,unsigned short readings[]);
int ForeRunnerSlot(void);
enum{voltageBufferOverflow=1<<0,voltageOverflow=1<<1,voltageUnderflow=1<<2};
#endif
/* HexToBinary.c */
int HexToBinary(char *string,void *ptr);
char *BinaryToHex(size_t n,void *ptr,char *string);
#if MAC_C
/* HideMenuBar.c */
void HideMenuBar(void);
void ShowMenuBar(void);
void SquareCorners(GDHandle device);
void RestoreCorners(GDHandle device);
void UnclipScreen(GDHandle device);
void RestoreScreenClipping(GDHandle device);
/* Identify.c */
char *IdentifyApplication(void);
char *IdentifyCompiler(void);
char *IdentifyGreenwichMeanTime(void);
char *IdentifyMachine(void);
char *IdentifyModel(void);
char *IdentifyOwner(void);
char *IdentifyVideo(GDHandle device);
char *IdentifyVM(void);
/* ImageStatistics */
double ImageEnergy(GWorldPtr aWorld,Rect *aRect,double background);
void ImageStatistics(GWorldPtr world,Rect *rect
,long *minPtr,long *maxPtr,double *meanPtr,double *meanSquarePtr);
/* InstallGestaltValue.c */
OSErr InstallGestaltValue(OSType selector,long response);
/* IsCmdPeriod.c */
Boolean IsCmdPeriod(EventRecord *event);
/* IsFileSharingOn.c */
Boolean IsFileSharingOn(void);
OSErr KillFileSharing(void);
#endif
/* IsNan.c */
int IsNan(double x);
int IsInf(double x);
#ifndef IsFinite /* neither NAN nor ±INF */
#define IsFinite(x) \
(sizeof(x)>8? \
((*(short *)&(x) & 0x7FFF)!=0x7FFF) /* 10 or 12 byte double */\
:((*(short *)&(x) & 0x7FF0)!=0x7FF0)) /* 8 byte double */
#endif
#if MAC_C
/* kbhit.c */
int kbhit(void);
int getcharUnbuffered(void);
/* KillEveryoneButMe.c */
OSErr KillEveryoneButMe(void);
#endif
/* Log2L.c */
long Log2L(unsigned long j);
#if MAC_C
/* MaximizeConsoleHeight.c */
void MaximizeConsoleHeight(void);
#endif
/* Mean.c */
double Mean(double x[],long n,double *sdPtr);
double MeanF(float x[],long n,double *sdPtr);
double MeanB(char x[],long n,double *sdPtr);
double MeanUB(unsigned char x[],long n,double *sdPtr);
double MeanW(short x[],long n,double *sdPtr);
double MeanUW(unsigned short x[],long n,double *sdPtr);
double MeanL(long x[],long n,double *sdPtr);
double MeanUL(unsigned long x[],long n,double *sdPtr);
/* Nan.c */
extern const short __NAN[];
#define Nan (*(double *)__NAN)
#if MAC_C
/* NoiseFill.c */
int NoiseFill(CWindowPtr window,Rect *r,double dx,double dy,Boolean randomPhase);
int NoiseFillBits(PixMap *bits,Rect *r,double dx,double dy,Boolean randomPhase);
int MakeNoise1(double dx,double dy,Boolean randomPhase,PixMap *bits); /* Obsolete */
/* NoisePdfFill.c */
OSErr NoisePdfFill(GWorldPtr world,Rect *rectPtr
,int pdf,double *meanPtr,double *sdPtr,int min,int max);
OSErr NoisePdfAdd(GWorldPtr world,Rect *rectPtr
,int pdf,double *meanPtr,double *sdPtr,int min,int max);
enum{kBinaryPdf=0,kBinomialPdf,kGaussianPdf,kUniformPdf};
#endif
/* Normal.c */
double NormalPdf(double x);
double Normal(double x);
double InverseNormal(double p);
double NormalSample(void);
double Normal2DPdf(double r);
double Normal2D(double r);
double InverseNormal2D(double p);
double Normal2DSample(void);
double InverseNormal2DPdf(double p);
void BoundedNormalIntegers(short *distribution,long n,double mean,double sd
,short min,short max);
/* nrand.c */
unsigned long nrand(unsigned long n);
/* OpenDataFiles.c */
unsigned long OpenDataFiles(FILE **inPtr,FILE **outPtr
,char *inName,char *outName);
/* OpenPreferencesFolder.c */
#if !MAC_C
#define OSErr short
#endif
OSErr OpenPreferencesFolder(void);
OSErr ClosePreferencesFolder(void);
OSErr OpenPreferencesWD(short *wdRefNumPtr);
#if !MAC_C
#undef OSErr
#endif
#if MAC_C
/* PixMapToPICT.c */
void PixMapToPICT(char *filename,PixMap **pm,Rect *rectPtr
,int pixelSize,ColorTable **cTable);
/* PixMapToPostScript.c */
void WindowToEPS(CWindowPtr window,char *filename,Rect *rectPtr
,Rect *pageRectPtr,double cellsPerInch,int grayLevels,float reflectance[256]);
void PixMapToEPS(char *filename,PixMap **pm,Rect *rectPtr
,Rect *pageRectPtr,double cellsPerInch,int grayLevels);
void PixMapToPostScript(char *filename,PixMap **pm,Rect *rectPtr
,Rect *pageRectPtr,double cellsPerInch,int grayLevels);
void AppendToFile(char *filename,char *string);
/* PlotXY.c */
typedef struct{
Boolean continuing; /* zero to start a new curve */
long color; /* e.g. blackColor, blueColor */
short lineWidth; /* in pixels, zero for none */
short symbolWidth; /* in pixels, zero for none */
short dashOffset; /* in pixels */
short dash[5]; /* in pixels. The array is terminated by a zero element */
short h,v; /* reserved for internal use */
Fixed pathLengthF; /* reserved for internal use */
} PlotXYStyle;
void PlotXY(WindowPtr window,double x,double y,PlotXYStyle *style);
#endif
/* PrintfExit.c */
int PrintfExit(const char *format,...);
#if MAC_C
/* PrintfGWorld.c */
void PrintfGWorld(GWorldPtr our);
void PrintStringAsBitmap(unsigned char *s);
#endif
/* PupilMTF.c */
double PupilMTF(double cPerDeg,double diameterMm,double wavelengthNm);
#if MAC_C
/* QD32Exists.c */
Boolean QD8Exists(void);
Boolean QD32Exists(void);
Boolean NewPaletteManager(void);
#endif
/* randU.c */
unsigned short randU(void);
unsigned long randUL(void);
void srandU(unsigned n);
void RandFill(void *address,long bytes);
/* ReadMATLABFile.c */
int LoadNamedMatIntoDoubles(FILE *f,const char *name,long *rows,long *cols
,double **real,double **imag);
int LoadNamedMatIntoShorts(FILE *f,const char *name,long *rows,long *cols
,short **real,short **imag);
int LoadNextMatIntoDoubles(FILE *f,char *name,long *rows,long *cols
,double **real,double **imag);
int LoadNextMatIntoShorts(FILE *f,char *name,long *rows,long *cols
,short **real,short **imag);
int SaveMatDoubles(FILE *f,char *name,long rows,long cols,double *real,double *imag);
int SaveMatShorts(FILE *f,char *name,long rows,long cols,short *real,short *imag);
#if MAC_C
/* RectToAddress.c */
unsigned char *RectToAddress(PixMap *pixMapPtr,Rect *rectPtr,short *rowBytesPtr,
short *pixelSizePtr,short *bitsOffsetPtr);
Ptr GetPixBaseAddr32(PixMap **pm);
#endif
/* Require.c */
void Require(long quickDrawVersion);
struct PrecompileSizeofInt{
int i;
};
struct PrecompileSizeofDouble{
double d;
};
#if MAC_C
/* RestoreCluts.c */
void RestoreCluts(void);
/* SetEntriesQuickly.c */
OSErr SetEntriesQuickly(GDHandle device,short start,short count,ColorSpec *table);
short macltset(GDHandle device,register short start
,unsigned short *red,unsigned short *green,unsigned short *blue,short count1);
short GetCardType(GDHandle device);
char *GetCardBase(GDHandle device);
OSErr WaitForNextBlanking(GDHandle device);
/* SetFileInfo.c */
void SetFileInfo(char *fileName,OSType fileType,OSType fileCreator);
/* SetGestaltValue1.c */
OSErr SetGestaltValue1(OSType selector,long response);
/* SetMouse.c */
void SetMouse(Point where);
/* SetOnePixel.c */
void SetPixmapPixel(PixMap *pmHandle,int x,int y,unsigned long value);
unsigned long GetPixmapPixel(PixMap *pmHandle,int x,int y);
unsigned char *GetPixmapPixelAddress(PixMap *pmHandle,int x,int y);
void SetDevicePixel(GDHandle device,int x,int y,unsigned long value);
unsigned long GetDevicePixel(GDHandle device,int x,int y);
void SetOnePixel(int x,int y,unsigned long value);
unsigned long GetOnePixel(int x,int y);
#define SetIPixel SetDevicePixel /* So that old programs won't break. */
#define GetIPixel GetDevicePixel /* So that old programs won't break. */
/* SetPixelsQuickly.c */
int SetPixelsQuickly(int x,int y,unsigned long value[],short n);
int GetPixelsQuickly(int x,int y,unsigned long value[],short n);
int SetWindowPixelsQuickly(WindowPtr window,int x,int y,unsigned long value[],short n);
int GetWindowPixelsQuickly(WindowPtr window,int x,int y,unsigned long value[],short n);
int SetDevicePixelsQuickly(GDHandle device,int x,int y,unsigned long value[],short n);
int GetDevicePixelsQuickly(GDHandle device,int x,int y,unsigned long value[],short n);
int SetPixmapPixelsQuickly(PixMapPtr pmPtr,int x,int y,unsigned long value[],short n);
int GetPixmapPixelsQuickly(PixMapPtr pmPtr,int x,int y,unsigned long value[],short n);
/* SetPriority.c */
void SwapPriority(char *priority);
void SetPriority(int i);
int GetPriority(void);
#endif
/* Shuffle.c */
void Shuffle(void *array,long elements,size_t elementSize);
#if MAC_C
/* SndPlay1.c */
OSErr SndPlay1(Handle snd);
void SndStop1(void);
short SndDone1(void);
/* StringToDateAndSecs.c */
double StringToDateAndSecs(char *string,DateTimeRec *date);
/* StringBounds.c */
void CharBounds(char a,Rect *bounds,long *count);
void StrBounds(char *s,Rect *bounds,long *count);
double StrOutlineLength(char *s);
void StringBounds(const unsigned char *s,Rect *bounds,long *count);
double StringOutlineLength(const unsigned char *s);
/* Timer.c */
struct Timer{
TMTask time;
long ourA5;
long interval,elapsed,elapsedIntervals;
long timeToStartTimer; /* minimum time in µs */
long stopDelay; /* µs from call to stop, re from call to start */
long timeManagerVersion;
struct Timer *next,*previous; /* doubly linked list of Timers */
};
typedef struct Timer Timer;
Timer *NewTimer(void);
void DisposeTimer(Timer *t);
void StartTimer(Timer *t);
long StopTimer(Timer *t); /* µs */
double StopTimerSecs(Timer *t); /* s */
long PeekTimer(Timer *t); /* µs */
double PeekTimerSecs(Timer *t); /* s */
/* TitleBarHeight.c */
int TitleBarHeight(WindowPtr window);
/* TrapAvailable.c */
Boolean TrapAvailable(short theTrap);
#endif
/* Uniform.c */
double UniformSample(void);
#if MAC_C
/* VBLInstall.c */
struct VBLTaskAndA5 {
volatile VBLTask vbl;
long ourA5;
#if USESROUTINEDESCRIPTORS || GENERATINGCFM
UniversalProcPtr subroutine;
#else
void (*subroutine)(struct VBLTaskAndA5 *vblData);
#endif
GDHandle device;
long slot;
volatile long newFrame; /* Boolean */
volatile long frame; /* count up from zero */
volatile long framesLeft; /* count down to zero */
long framesDesired;
Timer *frameTimer; /* time ms since last VBL interrupt, see Timer.c */
void *ptr; /* use this for whatever you want */
};
typedef struct VBLTaskAndA5 VBLTaskAndA5;
OSErr VBLInstall(VBLTaskAndA5 *vblData,GDHandle device,long frames);
OSErr VBLRemove(VBLTaskAndA5 *vblData);
void SimpleVBLSubroutine(VBLTaskAndA5 *vblData);
/* VideoTFB.c */
Boolean TFBInSlot(int slot);
void SetUpTFB(int slot);
void RampClutTFB(int slot);
void GrayClutTFB(int slot);
void LoadClutTFB(int slot,unsigned char rgb[256][3]);
void NewBlankingTFB(int slot);
void NewFieldTFB(int slot);
int BlankingTFB(int slot);
void SetDepthTFB(int slot,short int bits);
void SynchSetDepthTFB(int masterSlot,int slot,short int bits);
void SynchToMainDeviceTFB(GDHandle device);
void HaltTFB(int slot);
void RestartTFB(int slot,short int bits);
void HaltDeviceTFB(GDHandle device);
void RestartDeviceTFB(GDHandle device);
void ScrollTFB(int slot,short int bits,long x,long y);
void PanTFB(int slot,long int x);
#endif
/* VLambda.c */
double VLambda(double nm);
double VLambdaPrime(double nm);
#if MAC_C
/* Zoom.c */
void Zoom(WindowPtr theWindow,int zoomDir,EventRecord *event);
#endif
#endif /* _VIDEOTOOLBOX_ */